<template>
  <div class="flex">
    <el-card class="user w-1/3" shadow="hover">
      <template #header>
        <div class="card-header">
          <span>{{ t('profile.user.title') }}</span>
        </div>
      </template>
      <ProfileUser :user-profile="userProfile" />
    </el-card>
    <el-card class="user ml-3 w-2/3" shadow="hover">
      <template #header>
        <div class="card-header">
          <span>{{ t('profile.info.title') }}</span>
        </div>
      </template>
      <div>
        <el-tabs v-model="activeName" class="profile-tabs" style="height: 400px" tab-position="top">
          <el-tab-pane :label="t('profile.info.basicInfo')" name="basicInfo">
            <BasicInfo :user-profile="userProfile" @success="getUserProfile" />
          </el-tab-pane>
          <el-tab-pane :label="t('profile.info.resetPwd')" name="resetPasswd">
            <ResetPasswd />
          </el-tab-pane>
          <el-tab-pane :label="t('profile.info.userSocial')" name="userSocial">
            <UserSocial v-model:activeName="activeName" />
          </el-tab-pane>
        </el-tabs>
      </div>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import ProfileUser from './components/ProfileUser.vue'
import BasicInfo from './components/BasicInfo.vue'
import ResetPasswd from './components/ResetPasswd.vue'
import * as ProfileApi from '@/api/system/profile'
import UserSocial from './components/UserSocial.vue'

defineOptions({ name: 'Profile' })

const { t } = useI18n()
const activeName = ref('basicInfo')
// const userProfile = reactive({} as ProfileApi.ProfileVO)
const userProfile = ref({} as ProfileApi.ProfileVO)
const getUserProfile = async () => {
  // Object.assign(userProfile, await ProfileApi.getUserProfile())
  userProfile.value = await ProfileApi.getUserProfile()
}

onMounted(async () => {
  await getUserProfile()
})
</script>

<style scoped lang="scss">
.user {
  max-height: 960px;
  padding: 15px 20px 20px;
}

.card-header {
  display: flex;
  justify-content: center;
  align-items: center;
}

:deep(.el-card .el-card__header, .el-card .el-card__body) {
  padding: 15px !important;
}

.profile-tabs > .el-tabs__content {
  padding: 32px;
  font-weight: 600;
  color: #6b778c;
}

.el-tabs--left .el-tabs__content {
  height: 100%;
}
</style>
